<template>
  <div class="app-container">
    <van-nav-bar
        :title="pageTitle"
        left-text="返回"
        left-arrow
        class="custom-nav-bar"
        @click-left="onClickLeft"
        @click-right="onClickRight"
    >
      <!-- Vant 4 支持 #right 或 v-slot:right -->
      <template #right>
        <van-icon name="search" size="18" class="search-icon" />
      </template>
    </van-nav-bar>
    
    <div id="content" class="content-wrapper">
      <router-view class="fade-in-up"/>
    </div>
    
    <van-tabbar route @change="onChange" class="custom-tabbar">
      <van-tabbar-item to="/" icon="home-o" name="index" class="tabbar-item">
        <span class="tabbar-text">主页</span>
      </van-tabbar-item>
      <van-tabbar-item to="/team" icon="search" name="team" class="tabbar-item">
        <span class="tabbar-text">队伍</span>
      </van-tabbar-item>
      <van-tabbar-item to="/user" icon="friends-o" name="user" class="tabbar-item">
        <span class="tabbar-text">用户</span>
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>



<script setup lang="ts">
import { showToast } from 'vant';
import { useRoute, useRouter } from 'vue-router'
import { computed } from 'vue'

const route = useRoute()
const router = useRouter()

// 计算属性获取标题
const pageTitle = computed(() => {
  return route.meta.title || '找朋友'
})

const onClickLeft = () => {
  router.back();
};

const onClickRight = () => {
  router.push("/search");
};

const onChange = (index) => {
  // 可以添加切换动画效果
  showToast(`切换到标签 ${index}`);
};
</script>
<style scoped>
.app-container {
  min-height: 100vh;
  background: transparent;
  position: relative;
}

.custom-nav-bar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(102, 126, 234, 0.1);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
}

.search-icon {
  color: #667eea;
  transition: color 0.3s ease;
}

.search-icon:hover {
  color: #5a6fd8;
}

.content-wrapper {
  padding-bottom: 80px;
  min-height: calc(100vh - 120px);
  background: transparent;
}

.custom-tabbar {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(102, 126, 234, 0.1);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.tabbar-item {
  transition: all 0.3s ease;
}

.tabbar-item:hover {
  transform: translateY(-2px);
}

.tabbar-text {
  font-size: 12px;
  font-weight: 500;
  margin-top: 4px;
}

/* 路由切换动画 */
.router-view-enter-active,
.router-view-leave-active {
  transition: all 0.3s ease;
}

.router-view-enter-from {
  opacity: 0;
  transform: translateX(30px);
}

.router-view-leave-to {
  opacity: 0;
  transform: translateX(-30px);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .content-wrapper {
    padding-bottom: 70px;
  }
  
  .tabbar-text {
    font-size: 11px;
  }
}
</style>